<?php

abstract class Resume_Page_Abstract extends ME_Abstract_Page {
	/**
	 * @var ME_DAL_RefreshCacheLoader
	 */
	protected static $_cache;
	
	protected static $_dbGameData;
	
	protected function _loadDb() {
	}
	
	public function __construct(ME_Request $input, ME_Response $output) {
		$this->_loadDb();
		
		$output->execName = $input->execName = $input->getExecName();
		
		$output->actName = $input->actName = $input->getActionName();
		
		$output->ctlName = $input->ctlName = $input->getControllerName();
		
		$input->myLoginInfo = Libs_UcUser::checkLogin($input, $output);
		$uid = (int)$input->myLoginInfo['uid'];
		if( $uid > 0 ){ // hiall其他用户过来了，就在这个地方为它生产一个简历信息
			$db_resume = Db_Resume::instance();
			$sql = "SELECT * from resume_areapos WHERE uid=" . $uid;
			$row = $db_resume->getRow($sql);
			if( empty($row) ){
				$insert_sql = "insert into resume_areapos(uid) value(" . $uid . ")";
				$db_resume->query($insert_sql);
			}
		
		}
	}
	
	/**
	 * 初始化缓存
	 */
	public static function init() {
		self::$_cache = ME_DAL_RefreshCacheLoader::getInstance();
	}
	
	/**
	 * 加载缓存
	 * @return array DAL data
	 */
	protected static function loadCache($moduleName, $param = array(), $num = 0) {
		self::init();
		$data = self::$_cache->loadCacheObject($moduleName, $param);
		
		if( $num && $data && count($data) > $num ){
			$data = array_slice($data, 0, $num, true);
		}
		
		return $data;
	}
	
	/**
	 * 更新缓存
	 * 
	 * @param string $moduleName
	 * @param array  $param
	 * @return boolean
	 */
	protected static function refreshCache($moduleName, $param = array()) {
		self::init();
		return self::$_cache->refreshCacheObject($moduleName, $param);
	}
}
